package com.example.enums;

import java.util.HashMap;

public enum PetBreedEnum {
    狗(1), 猫(2), 鸟(3), 兔(4);

    private final Integer value;

    static private final HashMap<Integer,String> hashMap = new HashMap();

    static {  //类加载时只执行一次
        for(PetBreedEnum obj : values()){
            hashMap.put(obj.getValue(),obj.name());
        }
    }

    public static HashMap<Integer,String> getEnumsHashMap() {
        return hashMap;
    }
    PetBreedEnum(Integer value) {
        this.value = value;
    }

    static public String getName(Integer value) {
        return hashMap.get(value) == null ? "" : hashMap.get(value);
    }

    public Integer getValue() {
        return value;
    }
}
